﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- saved from url=(0014)about:internet -->
<head>
  <title>ECMAScript language features Test Suite</title>
</head>
<body>
  <script type="text/ecmascript">
    var br = "<br />\r\n";
    function writeBr() {
      document.writeln(br + br);
    }
    function getOutput(a, b) {
      return '<span style="color: ' + ((a == b) ? 'blue' : 'red') + ';" title="预期结果应为：' + b + '">' + a + '</span>';
    }

    (function callCallerTest() {
      document.write("call caller测试：" + getOutput(callCallerTest.caller == callCallerTest.call, false));
    }).call();
    writeBr();

    var leftVar = function namedFunction() { };
    document.write("右置命名函数测试：" + getOutput(typeof namedFunction, "undefined"));
    writeBr();

    document.write("DOM方法测试：" + getOutput(typeof window.open, "function"));
    writeBr();

    function xx() {
      //document.write(arguments.length + "<br/>");
      if(xx.caller == xx) {
        var x1 = xx;
        var x2 = xx.caller;

        document.write("强弱递归测试：" + [getOutput(xx.caller == xx.caller.caller, false), getOutput(xx.arguments == xx.caller.arguments, false), getOutput(xx.caller.arguments == xx.caller.arguments, true)]);

        return;
      }

      xx(1, 2);
    }
    xx(2);
    writeBr();

    try {
      document.write("Function eval测试：" + getOutput(typeof eval("function(){}"), "undefined"));
    } catch(ex) {
      document.write(ex.message || ex.description);
    }
    writeBr();

    document.write("(function) eval测试：" + getOutput(typeof eval("(function(){})"), "function"));
    writeBr();

    document.write("0,function eval测试：" + getOutput(typeof eval("0,function(){}"), "function"));
    writeBr();

    function myObject() {
      this.dontEnum = {};
    }
    myObject.prototype.nativeToString = myObject.prototype.toString;
    myObject.prototype.toString = function() {
      this.nativeToString();
    };
    var enumTestResult = [];
    var mo = new myObject;
    for(var name in mo) {
      if(!mo.propertyIsEnumerable(name))
        enumTestResult.push(name + ": " + mo.hasOwnProperty(name));
    }
    document.write("propertyIsEnumerable测试：" + enumTestResult.join(", "));
    writeBr();

    var icList = [], fromCharCode = String.fromCharCode;
    for(var i = 0; i < 0x10000; i++) {
      var c = fromCharCode(i);
      try {
        eval("'" + c + "'");
        eval('"' + c + '"');
      } catch(ex) {
        icList.push((i == 0 ? "" : c) + "(" + i.toString(16) + ")");
      }
    }
    document.write("需转义字符测试：" + icList.join());
    writeBr();

    //alert(new myObject().propertyIsEnumerable("toString"));
  </script>
</body>
</html>
